<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>在组件中使用v-model</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.js"></script>
</head>
<body>
<div id="case13-demo6">
    <h3>你现在卡里余额是:{{total}}</h3>
    <child-component v-model="total"></child-component>
</div>
<script type="text/javascript">
    var case13Demo6=new Vue({
        el:"#case13-demo6",
        data:{
            total:2000
        },
        components:{
            'child-component':{
                template:`
                <div>
                    <button v-on:click="handleincrease">+100</button>
                </div>`,
                data: function () {
                    return{
                        count:2000
                    }
                },
                methods:{
                    handleincrease:function () {
                        this.count=this.count+100
                        this.$emit('input',this.count)
                    }
                }
            }
        }
    })
</script>
</body>
</html>